import { Injectable, Inject, HttpException } from '@nestjs/common';
import { WECHAT_CLIENT, WECHAT_MODULE_OPTIONS } from './wechat.constants';
import { WechatModuleOptions } from './wechat.interface';
import { ApiConfig, SnsAccessTokenApi, Lang} from 'tnwx';

@Injectable()
export class WechatAuthService {
  constructor(
    @Inject(WECHAT_CLIENT) private readonly apiConfig: ApiConfig,
    @Inject(WECHAT_MODULE_OPTIONS)
    private readonly wechatOptions: WechatModuleOptions,
  ) {}

  getSnsAccessToken(code: string) {
    return SnsAccessTokenApi.getSnsAccessToken(code);
  }

  getUserInfo(access_token: string, openid: string) {
    return SnsAccessTokenApi.getUserInfo(access_token, openid, Lang.ZH_CN);
  }
}
